/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    isEnabled: { type: 'boolean' },
    // treeId: { type: 'string', _type: 'input', title: '目录', disabled: true, enableArea: [ 'detail' ], },
    name: {
      type: 'string',
      _type: 'string',
      title: '物料名称',
      disabled: true,
      enableArea: [ 'table', 'input', 'detail','search' ],
    },
    subcategory: {
      type: 'string',
      _type: 'string',
      title: '物料小类',
      enableArea: [ 'table', 'input', 'detail', ],
    },
    type: { type: 'string', _type: 'string', title: '类别', enableArea: [ 'table', 'input', 'detail','search', ], },
    spec: {
      type: 'string',
      _type: 'input',
      title: '物料规格',
      disabled: true,
      enableArea: [ 'table', 'input', 'detail','search', ],
    },
    number: {
      type: 'string',
      _type: 'input',
      title: '物料编号',
      disabled: true,
      enableArea: [ 'table', 'input', 'detail','search', ],
    },
    unit: {
      type: 'string',
      _type: 'input',
      title: '单位',
      disabled: true,
      enableArea: [ 'table', 'input', 'detail', ],
    },
    price: {
      type: 'number',
      _type: 'input',
      title: '单价',
      enableArea: [ 'table', 'input', 'detail', ],
      default: 0
    },
    count: {
      type: 'number',
      _type: 'input',
      title: '库存数量',
      enableArea: [ 'table', 'input', 'detail', ],
      default: 0
    },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('Store', _schema);
};
/**
 current: { type: 'number' },
 voltage: { type: 'number' },
 activePower: { type: 'number' },
 positiveActiveEnergy: { type: 'number' },
 ReverseActiveEnergy: { type: 'number' },
 currentA: { type: 'number' },
 currentB: { type: 'number' },
 currentC: { type: 'number' },
 voltageA: { type: 'number' },
 voltageB: { type: 'number' },
 voltageC: { type: 'number' },
 */
